import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { TNewBattleFieldBuffer } from "../../../Message/Db/Tables/TNewBattleFieldBuffer";
import { SkillStateConfig } from "./SkillStateConfig";
type int = number;
//class NewBattleFieldBufferConfig
    
    export  class NewBattleFieldBufferConfig
    {
        constructor()
        {
            
            if (NewBattleFieldBufferConfig._instance != null) 
            {
                throw new Error("NoviceGiftBagConfig 单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._dicNewBattleFieldBuffer = new Map<any, any> /* flash.utils.Dictionary */();
            var loc1=ConfigManager.instance.getJSONByFileName("t_new_battle_field_buffer.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new TNewBattleFieldBuffer();
                loc1.cost = loc2.cost;
                loc1.level = loc2.level;
                loc1.type = loc2.type;
                loc1.value = loc2.value;
                loc1.lowerCost = loc2.lowerCost;
                this._dicNewBattleFieldBuffer[loc1.type + "_" + loc1.level] = loc1;
            }
            return;
        }

        public getNewBattlefieldBuffer(arg1: int, arg2: int): TNewBattleFieldBuffer
        {
            return this._dicNewBattleFieldBuffer[arg1 + "_" + arg2];
        }

        public getSuccessRate(arg1: int): int
        {
            return this.getNewBattlefieldBuffer(0, arg1).value;
        }

        public getCost(arg1: int): int
        {
            return this.getNewBattlefieldBuffer(0, arg1).cost;
        }

        public getLowerCost(arg1: int): int
        {
            return this.getNewBattlefieldBuffer(0, arg1).lowerCost;
        }

        public getPersonalAttackPer(arg1: int): int
        {
            var loc1=this.getNewBattlefieldBuffer(1, arg1).value;
            return this.getStateEffect(loc1);
        }

        public getPersonalLifePer(arg1: int): int
        {
            var loc1=this.getNewBattlefieldBuffer(2, arg1).value;
            return this.getStateEffect(loc1);
        }

        public getHonorPer(arg1: int): int
        {
            return this.getNewBattlefieldBuffer(5, arg1).value;
        }

        public getAllAttackNumber(arg1: int): int
        {
            var loc1=this.getNewBattlefieldBuffer(3, arg1).value;
            return this.getStateEffect(loc1) / 1000;
        }

        public getAllLifeNumber(arg1: int): int
        {
            var loc1=this.getNewBattlefieldBuffer(4, arg1).value;
            return this.getStateEffect(loc1) / 1000;
        }

        /* internal  */getStateEffect(arg1: int): int
        {
            var loc1=SkillStateConfig.instance.getInfoByName(arg1);
            if (!loc1) 
            {
                return 0;
            }
            return loc1.stateEffect;
        }

        public static get instance(): NewBattleFieldBufferConfig
        {
            if (NewBattleFieldBufferConfig._instance == null) 
            {
                NewBattleFieldBufferConfig._instance = new NewBattleFieldBufferConfig();
            }
            return NewBattleFieldBufferConfig._instance;
        }

        /* internal */ /* var */_dicNewBattleFieldBuffer: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: NewBattleFieldBufferConfig;
    }
